home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROCS.ZIP / TYPECODE.ICN < prev    next >
Text File  |  1992-11-20  |  1KB  |  33 lines

  1. ############################################################################
  2. #
  3. #    File:     typecode.icn
  4. #
  5. #    Subject:  Procedures to produce letter code for Icon type
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     September 7, 1990
  10. #
  11. ###########################################################################
  12. #
  13. #  typecode(x) produces a one-letter string identifying the type of
  14. #  its argument. In most cases, the code is the first (lowercase)
  15. #  letter of the type, as "i" for the integer type. Structure types
  16. #  are in uppercase, as "L" for the list type. All records have the
  17. #  code "R".  The code "C" is used for the co-expression type to avoid
  18. #  conflict for the "c" for the cset type. In the case of X-Icon, "w"
  19. #  is produced for windows.
  20. #
  21. ############################################################################
  22.  
  23. procedure typecode(x)
  24.    local code
  25.                 # be careful of records and their constructors
  26.    if image(x) ? ="record constructor " then return "p"
  27.    if image(x) ? ="record" then return "R"
  28.    code := type(x)
  29.    if code == ("list" | "set" | "table" | "co-expression") then
  30.       code := map(code,&lcase,&ucase)
  31.    return code[1]
  32. end
  33.